home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / SCREEN.SWG / 0028_Very FAST FASTwrite.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-27  |  1KB  |  46 lines

  1. {
  2. SEAN PALMER
  3.  
  4. > I don't know if you'd be interested, but here's my version of a
  5. > direct-video writer: QWRITE.
  6.  
  7. I've optimized it a little, if you're interested... 8)
  8.  
  9. This is WITHOUT using inline ASM... I have routines that would put this
  10. optimized version to shame, in assembler....
  11.  
  12. This runs 2290 times in the time it took yours to run 1754 times in a
  13. test I ran.
  14.  
  15. I suggest removing the f and b parameters, and using the crt.textAttr
  16. variable so the user can set textcolor() and textbackground() before
  17. calling the routine and it'll come out ok, since you depend on crt
  18. anyway for the lastmode var... actually why not use wherex() and
  19. wherey() instead of passing THOSE as parameters too... hmm...
  20. }
  21.  
  22. procedure qwrite(x, y : byte; s : string; f, b : byte);
  23.  
  24. { Does a direct video write -- extremely fast.  <----hehehe
  25.   X, Y = screen location of first byte;
  26.   S = string to display;
  27.   F = foreground color;
  28.   B = background color. }
  29.  
  30. var
  31.   cnter  : word;
  32.   vidPtr : ^word;
  33.   attrib : word;
  34.  
  35. begin
  36.   attrib := swap((b shl 4) + f);
  37.   vidptr := ptr($B800, 2 * (80 * pred(y) + pred(x)));
  38.   if lastmode = 7 then
  39.     dec(longint(vidptr), $08000000);
  40.   for cnter := 1 to length(s) do
  41.   begin
  42.     vidptr^ := attrib or byte (s[cnter]);
  43.     inc(vidptr);
  44.   end;
  45. end;
  46.